
#include <src/xbase_connection.h>

#define CONFIG_FILE "xbase_client.conf"

// <command> cid "[cid]"
// <command> url "[url]"
int main(int argc, char **argv)
{
	if (argc != 3) {
		return 0;
	}

	std::string _arg = argv[1];
	std::string _value = argv[2];

	XBaseConnection _conn(CONFIG_FILE);


	if (_arg == "cid")	// cid -> url
	{
		std::string _cid_value = unhex(_value);
		
		XBaseCommandSelect _select;
		_select.set_table_name("sd_server_res");
		_select.set_row(_cid_value);
		_select.set_column("url:");
		_conn.execute_query(&_select);
		if(_select.fail())
		{
			cout << "query failed." << endl;
		}
		else
		{
			XBaseRecord &_result = _select.record();
			XBaseRecord::iterator _iter = _result.begin();
			for(;_iter != _result.end(); ++_iter)
			{
				std::cout << _iter << endl;
			}
		}
	}
	else if (_arg == "url")	// url -> cid
	{
	}
	else
	{
		cout << "unknown command." << endl;
		return;
	}
		
}
